<script>
	import dialog from '@/components/dialog/dialogUtils.js'

	export default {
		onLaunch: function() {
			console.log(uni.getStorageSync('onExit'),
				'onExit--------------------------------------------------------------');
			console.log('App Launch')
			uni['dialog'] = dialog;
			const windowInfo = uni.getWindowInfo();
			// 有未读才设置标记

			// #ifdef APP-PLUS

			//存在则关闭启动页进入首页
			plus.navigator.closeSplashscreen();
			// #endif
		},
		// onShow: function() {
		// 	console.log('App Show')

		// },
		onHide: function() {
			console.log('App Hide')
		},
		onExit() {
			uni.setStorageSync('onExit', new Date())
		},
		onShow() {
			getApp().globalData.$u = this.$u;
			// #ifdef APP-PLUS
			console.log('App Show');
			// uni.getClipboardData({
			// 	success: (res) => {
			// 		try {
			// 			// 解析msg
			// 			const messgae = res.data.substring(0, (res.data.indexOf('浏览器打开')))
			// 			// console.log(res.data, 999999, 10000, messgae);
			// 			// 解压 字符串
			// 			res.data = this.lzw_decode(messgae)
			// 			// 转为js对象
			// 			const data = res.data ? JSON.parse(res.data) : {}
			// 			if (data.title === 'lives-app') {
			// 				this.analysis(data)
			// 			}
			// 		} catch (e) {
			// 			console.log(e);
			// 			//TODO handle the exception
			// 		}
			// 	},
			// 	complete: function() { //结束之后清空剪切板
			// 		uni.setClipboardData({
			// 			data: '',
			// 			success: () => {
			// 				uni.hideToast()
			// 			}
			// 		});
			// 	}
			// });
			// h5打开app事件
			try {
				this.openApp()
			} catch (e) {
				//TODO handle the exception
			}
			// #endif
		},
		methods: {
			// 
			createdModel() {

			},
			// LZW解压
			lzw_decode(s) {
				let dict = {};
				let data = (s + '').split('');
				let currChar = data[0];
				let oldPhrase = currChar;
				let out = [currChar];
				let code = 256;
				let phrase;
				for (let i = 1, l = data.length; i < l; ++i) {
					let currCode = data[i].charCodeAt(0);
					if (currCode < 256) {
						phrase = data[i];
					} else {
						phrase = dict[currCode] && dict[currCode] || (oldPhrase + currChar);
					}
					out.push(phrase);
					currChar = phrase.charAt(0);
					dict[code] = oldPhrase + currChar;
					++code;
					oldPhrase = phrase;
				}
				return out.join('');
			},
			// 解析
			analysis(data) {
				switch (data.name) {
					case 'anchorHome':
						this.$u.route({
							name: data.name
						}, data.p)
						break;
					default:
						break;
				}
			},
			// 
			openApp() {
				var args = plus.runtime.arguments;
				if (args) {
					const url = '/' + (args.substring(args.indexOf('://') + 3))
					this.$u.route(url)
					// 只能跳转一次
					plus.runtime.arguments = ""
				}
			},

			onTabItemTap(e) {
				conosle.log(e)
			},

		},
	}
</script>

<style lang="scss">
	/* #ifndef APP-NVUE */
	@import "uview-ui/index.scss";
	@import "./static/css/public.scss";
	@import '@/static/icon/iconfont.css';

	// .uni-tabbar__item:nth-child(4) {

	// 	// background-color: red;
	// 	.uni-tabbar__icon {
	// 		width: 120rpx !important;
	// 		height: 120rpx !important;
	// 	}
	// }

	/* #endif */
	// /deep/ .uni-system-preview-image{
	// 	z-index: 99999999;
	// }
	// .uni-tabbar {
	// 	.uni-tabbar__item {
	// 		.uni-tabbar__icon {
	// 			width: 92rpx !important;
	// 			height: 92rpx !important;

	// 			img {
	// 				border-radius: 50%;
	// 			}
	// 		}
	// 	}
	// }
	::v-deep .uni-modal {
			.uni-modal__ft {
				.uni-modal__btn_primary {
					text-wrap: nowrap;
					padding:0 10rpx;
				}
			}
		}
		.u-avatar__level {
		  
		    border:none !important;
		    background-color: transparent !important;
		}
</style>